<script>
import { routeInterceptor } from './utils/permission.js';

export default {
  onLaunch: function () {
    console.log('App Launch');
    
    // 添加路由拦截
    this.initRouteInterceptor();
  },
  onShow: function () {
    console.log('App Show');
  },
  onHide: function () {
    console.log('App Hide');
  },
  methods: {
    // 初始化路由拦截器
    initRouteInterceptor() {
      // 拦截uni.navigateTo
      const navigateTo = uni.navigateTo;
      uni.navigateTo = (options) => {
        if (routeInterceptor(options)) {
          navigateTo(options);
        }
      };
      
      // 拦截uni.redirectTo
      const redirectTo = uni.redirectTo;
      uni.redirectTo = (options) => {
        if (routeInterceptor(options)) {
          redirectTo(options);
        }
      };
      
      // 拦截uni.switchTab
      const switchTab = uni.switchTab;
      uni.switchTab = (options) => {
        if (routeInterceptor(options)) {
          switchTab(options);
        }
      };
      
      // 拦截uni.reLaunch
      const reLaunch = uni.reLaunch;
      uni.reLaunch = (options) => {
        if (routeInterceptor(options)) {
          reLaunch(options);
        }
      };
    }
  }
}
</script>

<style lang="scss">
@use './static/styles/iconfont.scss';

/*每个页面公共css */
page {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica,
    Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei',
    sans-serif;
  height: 100%;
  box-sizing: border-box;
}

/* tabBar样式调整 */
.uni-tabbar {
  box-shadow: 0px -2px 5px rgba(0, 0, 0, 0.05);
}

.uni-tabbar__item-text {
  font-size: 12px;
  line-height: 1.2;
  color: #bcaaa4;
}

.uni-tabbar__item-text.uni-tabbar__item-text-selected {
  color: #8d6e63;
}

.uni-tabbar__icon {
  width: 24px;
  height: 24px;
}

/* 隐藏下拉刷新组件 */
.uni-page-refresh,
.uni-page-refresh-inner,
uni-page-refresh,
uni-page-refresh-inner {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}
</style>
